// import 'package:decimal/decimal.dart';
// import 'package:get/get.dart';
// import 'package:star_author/provider/webview_page.dart';
// import 'package:star_author/utils/utils.dart';
// import 'package:provider/provider.dart';

import 'package:star_author/model/backflow.dart';
import 'package:star_author/utils/utils.dart';

class _DeductGuaranteeFromBidder {
  late int id;
  late String expectedDeductGuaranteeAt;
  late String price;
  late String status;
  late String? deductAt;

  _DeductGuaranteeFromBidder(Map item) {
    this.id = item['id'];
    this.expectedDeductGuaranteeAt = item['expected_deduct_guarantee_at'];
    this.price = item['price'];
    this.status = item['status'];
    this.deductAt = item['deduct_at'];
  }
}

class TenderOrderModel {
  late int id;
  late String number;
  late String originalStatus;
  late String? createdAt;
  late bool onsale_can_evaluated_again;
  late String? updatedAt;
  late String? back_code;
  late String? backflow_received_address;
  late String? backflow_received_address_without_mobile;
  late String priceStr;
  late double price;
  late String? paidAt;
  late String? finishedAt;
  late String? closedAt;
  late String? payExpiredAt;
  late _DeductGuaranteeFromBidder deductGuaranteeFromBidder;
  late BackflowModel? kloneBackflow;
  late int backflowId;
  late String? winningExpectedConfirmAt;
  late bool? winningAfterSaling;
  late bool? cancel_onsale;
  late String? winningPaidAt;
  late String? winningAfteSaleAt;
  late String? winningShippedAt;
  late String? takenBackAt;
  late String? rate_for_tender;
  late Map back_address;
  late Map originalData;

  TenderOrderModel(Map item) {
    this.originalData = item;
    this.id = item['id'];
    this.rate_for_tender = item['rate_for_tender'];
    this.back_address = item['back_address'] ?? {};
    this.back_code = item['back_code'] ?? "";
    this.backflow_received_address = item['backflow_received_address'] ?? "";
    this.backflow_received_address_without_mobile =
        item['backflow_received_address_without_mobile'] ?? "";
    this.number = item['number'];
    this.originalStatus = item['status'];
    this.createdAt = item['created_at'];
    this.onsale_can_evaluated_again =
        item['onsale_can_evaluated_again'] ?? false;
    this.updatedAt = item['updated_at'];
    this.priceStr = formatPrice(item['price']);
    this.price = double.parse((this.priceStr));
    this.paidAt = item['paid_at'];
    this.finishedAt = item['finished_at'];
    this.closedAt = item['closed_at'];
    this.payExpiredAt = item['pay_expired_at'];
    this.winningExpectedConfirmAt = item['winning_expected_confirm_at'];
    this.winningAfterSaling = item['winning_after_saling'];
    this.cancel_onsale = item['cancel_onsale'];
    this.winningPaidAt = item['winning_paid_at'];
    this.winningAfteSaleAt = item['winning_after_sale_at'];
    this.winningShippedAt = item['winning_shipped_at'];
    this.takenBackAt = item['taken_back_at'];

    this.deductGuaranteeFromBidder =
        new _DeductGuaranteeFromBidder(item['deduct_guarantee_from_bidder']);
    Map<dynamic, dynamic>? _kloneBackflow = item['klone_backflow'];
    if (checkNotNullOrNotEmpty(_kloneBackflow)) {
      this.kloneBackflow = new BackflowModel(_kloneBackflow!);
    } else {
      this.kloneBackflow = null;
    }
    this.backflowId = item['backflow_id'];
  }
}
